﻿#region  文件信息
// ---------------------------------------------------------------------------------------
// <copyright file="PayFenzhangSub.cs" company="">
// 作者：李帅伦
// </copyright>
// <summary>
// 类型简介：
// 类型详细：PayFenzhangSub.cs
// 创建时间：2015-01-15 11:28
// 修改时间：2015-01-15 11:28
// </summary>
// ---------------------------------------------------------------------------------------
#endregion
namespace Payment.ChinaPay
{
    using System.Collections.Generic;

    /// <summary>
    /// The pay fenzhang sub.
    /// </summary>
    public class PayFenzhangSub : PaySub
    {
        /// <summary>
        /// The service.
        /// </summary>
        private PayService service;

        /// <summary>
        /// The operation.
        /// </summary>
        public PayOperation operation { get; private set; }

        /// <summary>
        /// 分账信息
        /// </summary>
        public string ShareData { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="PayFenzhangSub"/> class.
        /// </summary>
        /// <param name="service">
        /// The service.
        /// </param>
        /// <param name="config">
        /// The config.
        /// </param>
        public PayFenzhangSub(PayService service, ChinaPayConfig config)
            : base(service, config)
        {
            operation = new PayOperation(service, config);
            this.Gateway = "http://apps.chinapay.com/cpeduinterface/OrderGet.do";
        }

        /// <summary>
        /// 版本号
        /// </summary>
        public override string Version
        {
            get
            {
                return "20100401";
            }
        }

        /// <summary>
        /// 写入data
        /// </summary>
        /// <returns></returns>
        protected override Dictionary<string, string> GetSubData()
        {

            var data = new Dictionary<string, string>
                        {
                            { "MerId", this.operation.Service.MerId },
                            { "BusiId" ,"00010001"},
                            { "OrdId", this.operation.Service.OrdId },
                            { "OrdAmt", this.operation.Service.OrdAmt },
                            { "CuryId", this.operation.Service.CuryId },
                            { "Version", this.Version },
                            { "BgRetUrl",  this.operation.Service.NoticeUrl },
                            { "PageRetUrl", this.operation.Service.ReturnUrl },
                            {"GateId","0001"},
                            { "ShareType", "0001" },
                            { "ShareData", this.ShareData },
                             { "Priv1", "" },
                             {"CustomIp",""}
                        };

            data.Add("ChkValue", this.operation.Sign(data));

            return data;
        }

        public string PlainData { get; private set; }
    }
}